
<!DOCTYPE html>
<html xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="UTF-8">
    <title>体检项</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div id="CheckUpdiv">
<div>
    <div class="x-nav">
            <a>
              <cite>体检项</cite></a>
        <a class="layui-btn layui-btn-primary layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:38px">ဂ</i></a>
    </div>
<table class="layui-table">
    <thead>
    <tr>
        <th>请选择需要体检的项目</th>
        <th>体检项</th>
        <th>检查方法</th>
        <td>
            <input type="checkbox" v-on:click="cheall" id="cheall" style="height: 20px;width: 20px"/>
        </th>
    </tr>
    </thead>
    <tbody>
    <tr v-for="com in CommonResult.data" id="list">
        <td>{{com.cuid}}</td>
        <td>{{com.cname}}</td>
        <td>{{com.cumethod}}</td>
        <td>
           <input type="checkbox" style="height: 20px;width: 20px" @click="che" class="cheall" v-bind:value="com.cuid">
        </td>
    </tr>
    </tbody>
</table>
</div>

<div style="margin-left: 640px; margin-top: 56px; ">
    <button class="layui-btn" type="button" v-on:click="xiaYiBu" lay-submit="" lay-filter="sreach">下一步</button>
</div>
</div>
<script src="/js/vue.js"></script>
<script>

    $(function () {
        var CheckUpdiv = new Vue({
            el : "#CheckUpdiv",
            data(){
                return{
                    CommonResult:{
                        data: ""
                    },
                    cid : ""
                };
            },
            mounted(){
                var _this = this;
                $.ajax({
                    url: "/getAllCheckUp",
                    type : "post",
                    success:function (result) {
                        _this.CommonResult = result;
                    }
                })
            },
            methods:{
                cheall : function () {
                    var _cheall = $(".cheall");
                    if ($("#cheall")[0].checked){
                        for (var i=0; i<_cheall.length;i++){
                            _cheall[i].checked = true;
                        }
                    } else {
                        for (var i=0; i<_cheall.length;i++){
                            _cheall[i].checked = false;
                        }
                    }
                },
                che : function(){
                    var che1 = $(".cheall");
                    var che2 = $(".cheall:checked");
                    if (che1.length == che2.length){
                        $("#cheall")[0].checked = true;
                    } else {
                        $("#cheall")[0].checked = false;
                    }

                },
                xiaYiBu : function () {
                    var _this = this;
                    var cheall = $(".cheall");
                    var cuids = new Array();
                    var j=0;
                    for (var i=0; i<cheall.length;i++){
                        if (cheall[i].checked == true){
                            cuids[j] = cheall[i].value;
                            j++;
                        }
                    }
                    if (cuids.length == "" ){
                        layer.msg("请选择检测项", {time: 1000, icon: 5, shift: 6});
                    }else{
                        layer.open({
                            title: ['提示'],
                            content : '您选择的项目有'
                                +cuids,
                            btn : ['确定','返回'],
                            shadeClose : true,
                            time : 5000,
                            yes : function () {
                                window.location.href="/userDetection/examiner_projects?cuids="+cuids;
                            }
                        })
                    }
                }
            }
        });
    })
</script>
</body>

</html>